#ifndef STATUSBAR_H_
#define STATUSBAR_H_

#include <irrlicht.h>

#include "../Logger.h"

#include "ContainedNode.h"

using namespace irr;

class CGUIStatusBar : public irr::gui::IGUIElement {
		video::SColor m_color; // racism!?
		float m_percent;
		s32 m_width; s32 m_height;
		core::stringw m_text;
	public: // hair
		CGUIStatusBar(const irr::core::rect<s32>& area, irr::gui::IGUIEnvironment* environ, s32 width, s32 height);
		virtual ~CGUIStatusBar();
		void draw(); // whar iz muh penkil

		void setPercent(float per);
		const float& getPercent() const;
		
		void setColor(const video::SColor& col);
		const video::SColor& getColor() const;

		void updateLocation(const core::position2di& pos); // DOKO NI
};

class StatusBar : public ContainedNode {
	protected:
	
		float m_percent;
		irr::video::SColor m_barColor;
//		irr::scene::IBillboardSceneNode* m_barNode;
		CGUIStatusBar* m_bar;
		void CreateStatusBar();
	public:
		
		StatusBar(irr::scene::ISceneNode* parent, float offset, irr::scene::ISceneManager* scn);
		StatusBar(irr::scene::ISceneNode* parent, float offset, const irr::video::SColor& col, irr::scene::ISceneManager* scn);
		StatusBar(irr::scene::ISceneNode* parent, float offset, const irr::video::SColor& col, float width, float height, irr::scene::ISceneManager* scn);		

		virtual ~StatusBar() { 
			m_bar->remove();
		}
		
		void changeColor(const irr::video::SColor& col) {
			m_barColor = col;
			m_bar->setColor(m_barColor);
		}		
		
		void updatePercent(float val) { 
			m_percent = val;
			m_bar->setPercent(m_percent);
		}
		
		float getPercent() { return m_percent; }		

		void setVisible(bool t) { m_bar->setVisible(t); }
		bool isVisible() { return m_bar->isVisible(); }
		
		void updateLocation() {
			core::vector3df temp = m_parent->getAbsolutePosition();
			temp.Y+=m_offset;
			irr::core::position2di temppos = m_sceneManager->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition(temp);
			m_bar->updateLocation(temppos);
		}
};

#endif /*STATUSBAR_H_*/
